<template>
  <div>
      <h1>{{msg}}</h1>
      <h2>{{result}}</h2>
  </div>
</template>
<script>
export default {
  created: function() {
    this.result = this.compare(this.arr);
  },
  data() {
    return {
      msg: "hello yue",
      arr: [3, 2, 1, 4, 5],
      result: 0
    };
  },
 
  methods: {
    compare: function(arr) {
        for(var i=0;i<arr.length;i++){
      for (var j = 0; j < arr.length - i; j++) {
        if (arr[j] > arr[j + 1]) {
          var temp = arr[j];
          arr[j] = arr[j + 1];
          arr[j + 1] = temp;
        }
      }
    }
   return arr
    }
     
  }
};
</script>

